package com.hzjq.fxlib.presenter

import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.view.KeyEvent
import android.view.ViewGroup
import com.hzjq.fxlib.R
import com.wxl.common.util.DPUtil
import kotlinx.android.synthetic.main.register_ok_layout.view.*

class RegisterFinishPresenter : AbsViewPresenter {

   private var runnable: Runnable?=null

    constructor(rootView: ViewGroup) : super(rootView)

    override fun onContentViewId(): Int {
        return R.layout.register_ok_layout
    }

    override fun onResume() {
        (rootView.registerOkLayout.background as GradientDrawable).setColor(Color.parseColor("#8899cc00"))
        (rootView.registerOkLineView.background as GradientDrawable).setStroke(DPUtil.dip2px(2),Color.parseColor("#8899cc00"))
    }

    override fun showAction(action: String) {
        rootView.registerOkCount.text = action
    }

    fun showCapCount(count:Int){
        rootView.registerCapCount.text = "$count 发"
    }

    fun setClickCallback(runnable: Runnable) {
        this.runnable = runnable
    }


    override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
        if (keyCode == KeyEvent.KEYCODE_F4 || keyCode == KeyEvent.KEYCODE_F8) {
            runnable?.run()
            return true
        }
        return super.onKeyDown(keyCode, event)
    }
}